package com.repeat.member.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 广播发送消息
 */
@Configuration
public class RabbitFanoutConfig {
    public static final String QUEUE_NAME = "repeat.member";
    public static final String QUEUE_NAME2 = "repeat.member2";
    public static final String EXCHANGE_NAME = "repeat.member.exchange";


    @Bean
    public FanoutExchange FanoutExchange() {
        return new FanoutExchange(EXCHANGE_NAME);
    }
    @Bean
    public Queue QueueMember1() {
        return new Queue(QUEUE_NAME);
    }

    @Bean
    public Binding BindingMember() {
       return BindingBuilder.bind(QueueMember1()).to(FanoutExchange());
    }

    @Bean
    public Queue QueueMember2() {
        return new Queue(QUEUE_NAME2);
    }

    @Bean
    public Binding BindingMember2() {
        return BindingBuilder.bind(QueueMember2()).to(FanoutExchange());
    }
}
